package org.sbbs.admin.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.NaturalId;
import org.sbbs.admin.enumeration.DictTypeEnum;
import org.sbbs.base.jpa.entity.BaseEntity;

import java.util.List;

/**
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "sys_dict")
@Comment("系统字典表")
public class SysDict extends BaseEntity {
    private static final long serialVersionUID = -385657412750545068L;
    @Enumerated(EnumType.STRING)
    @Comment("字典分类SYS系统BIZ业务")
    private DictTypeEnum type;

    /**
     * 标识
     */
    @Column(name = "dict_key", length = 50)
    @Comment("字典KEY")
    @NaturalId
    private String key;

    /**
     * 名称
     */
    @Column(name = "dict_name", length = 50)
    @Comment("字典名称")
    private String name;

    /**
     * 状态
     */
    @Basic
    @Comment("启用状态1启用0未启用")
    private Boolean state;

    /**
     * 备注
     */
    @Column(name = "remark", length = 500)
    @Comment("备注")
    private String remark;
//
    @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
    private List<SysDictItem> items;
}
